#!/bin/bash
#-n代表判断字符串的长度，如果字符串长度为0，返回false,否则返回true
if [ -n "$2" ]
then
	do_date=$2
else
	#echo 必须给我传一个日期
	#exit
	do_date= $(date -d yesterday +%F) 
fi

echo 当前要操作的日期是$do_date

ads_coupon_stats="

"
ads_new_order_user_stats="

"
ads_order_by_province="

"
ads_order_continuously_user_count="

"
ads_order_to_pay_interval_avg="

"
ads_page_path="

"
ads_repeat_purchase_by_tm="

"
ads_sku_cart_num_top3_by_cate="

"
ads_sku_favor_count_top3_by_tm="

"
ads_trade_stats_by_cate="

"
ads_trade_stats_by_tm="

"
ads_traffic_stats_by_channel="

"
ads_user_action="

"
ads_user_change="

"
ads_user_stats="

"


case $1 in
"ads_coupon_stats")
   hive --database gmall -e "$ads_coupon_stats"
   ;;
"ads_new_order_user_stats")
   hive --database gmall -e "$ads_new_order_user_stats"
   ;;
"ads_order_by_province")
   hive --database gmall -e "$ads_order_by_province"
   ;;
"ads_order_continuously_user_count")
   hive --database gmall -e "$ads_order_continuously_user_count"
   ;;
"ads_order_to_pay_interval_avg")
   hive --database gmall -e "$ads_order_to_pay_interval_avg"
   ;;
"ads_page_path")
   hive --database gmall -e "$ads_page_path"
   ;;
"ads_repeat_purchase_by_tm")
   hive --database gmall -e "$ads_repeat_purchase_by_tm"
   ;;
"ads_sku_cart_num_top3_by_cate")
   hive --database gmall -e "$ads_sku_cart_num_top3_by_cate"
   ;;
"ads_sku_favor_count_top3_by_tm")
   hive --database gmall -e "$ads_sku_favor_count_top3_by_tm"
   ;;
"ads_trade_stats_by_cate")
   hive --database gmall -e "$ads_trade_stats_by_cate"
   ;;
"ads_trade_stats_by_tm")
   hive --database gmall -e "$ads_trade_stats_by_tm"
   ;;
"ads_traffic_stats_by_channel")
   hive --database gmall -e "$ads_traffic_stats_by_channel"
   ;;
"ads_user_action")
   hive --database gmall -e "$ads_user_action"
   ;;
"ads_user_change")
   hive --database gmall -e "$ads_user_change"
   ;;
"ads_user_retention")
   hive --database gmall -e "$ads_user_retention"
   ;;
"ads_user_stats")
   hive --database gmall -e "$ads_user_stats"
   ;;
"all")
   hive --database gmall -e "$ads_coupon_stats$ads_new_order_user_stats$ads_order_by_province$ads_order_continuously_user_count$ads_order_to_pay_interval_avg$ads_page_path$ads_repeat_purchase_by_tm$ads_sku_cart_num_top3_by_cate$ads_sku_favor_count_top3_by_tm$ads_trade_stats_by_cate$ads_trade_stats_by_tm$ads_traffic_stats_by_channel$ads_user_action$ads_user_change$ads_user_retention$ads_user_stats"
   ;;
esac
